package com.hevs.samplewebapp.server.dao;



/**
 * 
 * Factory for getting the DAO without wasting ressources with multiple instanciations
 * @author Arnaud Durand
 * @date 26.03.12
 */
public class DAOImplFactory implements DAOFactory{

	/**
	 * Initialization of the instance of the DAOFactory
	 */
	private final static DAOImplFactory INSTANCE = new DAOImplFactory();
	
	/**
	 * Initialization of the MedicalRecordDAO to use the datanucleus
	 */
	private  MedicalRecordDAO medicalRecordDAO = new MedicalRecordDAOImpl();
	
	/**
	 * Initialization of the UserDAO to use the datanucleus
	 */
	private  UserDAO userDAO = new UserDAOImpl();
	
	/**
	 * Initialization of the internalMessageDAO to use the datanucleus
	 */
	private  InternalMessageDAO internalMessageDAO = new InternalMessageDAOImpl();
	
	/**
	 * Constructor of the DAOImplFactory
	 */
	private DAOImplFactory() {
		this.medicalRecordDAO= new MedicalRecordDAOImpl();
		this.userDAO = new UserDAOImpl();
		this.internalMessageDAO = new InternalMessageDAOImpl();
	}
	
	/**
	 * Getter for the Instance of the DAO
	 * @return
	 * the Instance to use
	 */
	public static DAOImplFactory getInstance() {
        return INSTANCE;
	}

	@Override
	/**
	 * Getter for the MedicalRecordDAO
	 */
	public  MedicalRecordDAO getMedicalRecordDAO() {
		return medicalRecordDAO;
	}
	
	@Override
	/**
	 * Getter for the InternalMessageDAO
	 */
	public  InternalMessageDAO getInternalMessageDAO() {
		return internalMessageDAO;
	}

	@Override
	/**
	 * Getter for the UserDAO
	 */
	public UserDAO getUserDAO() {
		return userDAO;
	}
}
